
package org.apache.ocean;

import org.apache.commons.lang.builder.*;
import org.apache.commons.lang.*;

/**
 *
 * @author jasonr
 */
public class IDVersion {
  public CLong id;
  public CLong version;
  public String shardID;
  
  public IDVersion() {}
  
  public IDVersion(CLong id, CLong version) {
    this.id = id;
    this.version = version;
  }
  
  public IDVersion(CLong id, CLong version, String shardID) {
    this.id = id;
    this.version = version;
    this.shardID = shardID;
  }
  
  public void illegalArgs() {
    if (id == null) throw new IllegalArgumentException("id null");
    if (version == null) throw new IllegalArgumentException("version null");
  }
  
  public String toString() {
    return id+"_"+version;
  }
  
  public boolean equals(Object object) {
    if (!(object instanceof IDVersion)) return false;
    if (object == null) return false;
    IDVersion other = (IDVersion)object;
    return ObjectUtils.equals(id, other.id) && ObjectUtils.equals(version, other.version) && ObjectUtils.equals(shardID, other.shardID);
  }
  
  public int hashCode() {
    HashCodeBuilder builder = new HashCodeBuilder();
    builder.append(id);
    builder.append(version);
    builder.append(shardID);
    return builder.toHashCode();
  }
}
